<?php slot('coursesNav', 'active') ?>

<div id="wrapper">
	<?php include_partial('global/systemMessages', array('form' => $form)) ?>
	<div id="content">
	
	<!-- 
		<div id="location-bar">
			<form method="post" action="">
				<fieldset>
					<select>
						<option>Harvard</option>
					</select>
				</fieldset>
			</form>
			<ul class="breadcrumbs">
				<li class="first">
					<a href="#">Fall 2008 &#xBB;</a>
				</li>
				<li>
					<a href="#">Positive Psychology &#xBB;</a>
				</li>
				<li>Write Notes</li>
			</ul>
		</div>
	-->	
		
		<div id="main">
			<div class="main-heading">
				<h1>Write Notes</h1>
				<h2><?php echo $course->getSubject() ? $course->getSubject()->getName().":" : "" ?> <?php echo $course->getName() ?></h2>
			</div>
			<form method="post" action="<?php echo url_for('notes/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id='.$form->getObject()->getId() : '')) ?>" class="notes-writer">
				<h4>
					<span>Course Selection</span>
				</h4>
				<fieldset>
			
						<label>Course Subject</label>
						<div class="course-subject-select">
						<select id="subject_select">
							<?php foreach($subjects as $subject):?>
								<?php if($course->getSubject()->getId() == $subject->getId()):?>
							
									<option value="<?php echo $subject->getId()?>" size="10" selected="selected"><?php echo $subject->getName()?></option>
								<?php else:?>
									<option value="<?php echo $subject->getId()?>" size="10"><?php echo $subject->getName()?></option>
								<?php endif?>
							<?php endforeach?>
						</select>
						</div>

					<br/>
					
						<label>Course</label>
						
						<div class="course-select">
						<select id="course_id" name="note[course_id]">
							<?php include_component('courses', 'selectbox', array('course_id'=>$course->getId(), 'subject_id'=>$course->getSubject()->getId()))?>
						</select>
						</div>
						
				</fieldset>
				
				<h4>
					<span>Lecture Number and Title</span>
				</h4>
				<fieldset>
					<div class="lecturer-input">
						<label>Lecture Number</label>
						<?php echo $form['number']->render(array('class' => 'input-text', 'id' => 'lecture-number',
							'style' => 'width: 30px;')) ?>
						
					</div>
					<div class="guest-lecturer" id="toggleGuestLecturer">
						<p>
							<a href="javascript:void(0)" id="guestLecturerLink">Guest Lecturer?</a>
						</p>
					</div>
					<div class="guest-lecturer" style="display: none;" id="guestLecturer">
						<div class="lecturer-input">
							<label>Lecturer's Name</label>
							<?php echo $form['lecturer_name']->render(array('class' => 'input-text')) ?>
						</div>
						<div class="lecturer-input">
							<label>Lecturer's Email</label>
							<?php echo $form['lecturer_email']->render(array('class' => 'input-text')) ?>							
						</div>
					</div>
					<label class="clearer">Lecture Topic</label>
					<?php echo $form['topic']->render(array('class' => 'input-text', 'id' => 'lecture-topic')) ?>
				</fieldset>
				<h4>
					<span>Lecture Notes</span>
				</h4>
				<div style="margin: 20px 0px 20px 0px;">
					<?php 
						$oFCKeditor->Create();
						// include whiteboard
						$oWhiteboard = FCKDrawUtil::getFCKDrawWhiteBoard($oFCKeditor,'note[board]');
						$oWhiteboard->Create();
					?>
				</div>
				<h4>
					<span>Note Tags</span> 
				</h4>
				<div style="margin: 20px 0px 20px 0px;">
					<?php echo $form['tags']->render(array('class'=>'input-text','id'=>'lecture-tags')) ?>
				</div>
				<h4>
					<span>Lecture Details</span>
				</h4>
				<fieldset>
					<label>Lecture Summary</label>
					<?php echo $form['summary']->render(array('id' => 'lecture-summary')) ?>
					<label>Lecture Date</label>
					<div class="lecture-date">
						<div class="inner">
							<?php echo $form['noted_at']->render() ?>
							<a href="javascript:void(0);" class="btn_calendar">&nbsp;</a><br>
						</div>
						
						<br />
						<label>Semester</label>
						<?= $form['semester_id']->render() ?>

						<br /><br />
						<?php if ($sf_user->isLoggedInFacebookUser()): ?>
							<input type="checkbox" name="publish_to_facebook" value="publish" checked="checked" />&nbsp;Publish to Facebook Feed
						<?php endif; ?>
						
					</div>
					<!-- only show share box if they are the creator of note or admin of group -->
					<?php if($sf_user->isAdmin() || $form->isNew() || $sf_user->isGroupAdmin($note->getGroupId()) || $sf_user->getId() == $note->getUserId()): ?>
						<div class="share-with">
							<div class="inner">
								<p>Share with:</p>
								<?php $visibilityOptions = $form['visibility']->getWidget()->getOption('choices') ?>
								<ul>
									<?php foreach($visibilityOptions as $value => $name): ?>
									<li>
										<label>
											<input type="radio" 
												value="<?php echo $value ?>"
												 name="note[visibility]"
												 <?php echo $form['visibility']->getValue() == $value ? 'checked="checked"' : '' ?>
												 /><?php echo $name ?>
										</label>
									</li>
									<?php endforeach ?>
								</ul>
							</div>
						</div>
				<?php endif ?>
				</fieldset>

				<?php if(!isset($isNew) || !$isNew) { ?>
				<h4><span>Change Notes</span></label>
				<fieldset>
					<div class="version-notes">
						<label>Please describe your reason for this edit:</label>
						<div class="inner">
							<input type="text" name="version_notes" style="width: 100%" />
						</div>
					</div>
				</fieldset>
				<?php } ?>

				<fieldset class="form-submit">
					<?php echo $form->renderHiddenFields() ?><!--
				
					<input type="hidden" id="hidden_course_id" name="course_id" value="<?php echo $course->getId() ?>" />


					--><input type="hidden" name="task_id" value="<?php echo $sf_request->getParameter('task_id') ?>" />
					<input type="hidden" name="group_id" value="<?php echo $sf_request->getParameter('group_id') ?>" />
					<input type="image" alt="Save Your Notes" src="/images/btn_save-notes.gif"/>
				</fieldset>
			</form>
		</div>
		<div id="sidebar">
			<div class="module about">
				<h3 class="gradient dark">About <?php echo $course->getName() ?></h3>
				<div class="inner">
					<p><?php echo $course->getDescription()?></p>
					<div class="course-details">
						<p>
							<strong>Instructor: </strong>
							<a href="javascript:void(0);"><?php echo $course->getInstructorName() ?></a>
						</p>
						<p><!-- <strong>Note Takers: </strong> --></p>
					</div>
				</div>
			</div>
		</div>
	</div>

</div>

<script type="text/javascript">

//function for subject and course dropdown generator
function bindSubjectSelector()
{
	$('#subject_select').change(function(){

		subject_id = $(this).val();
		changeSubject(subject_id);
	});
}

function changeSubject(id)
{
	$.get('<?php echo url_for('courses/selectbox')?>',
			{subject_id: id},
			function(data){

				console.log(
						$('#course_id').html()
						);

				
				$('#course_id').html(data);
			});
}


	$(document).ready(function(){
		$('#guestLecturerLink').click(function(){
			$('#guestLecturer').show();
			$('#toggleGuestLecturer').hide();
		});

		bindSubjectSelector();
		});
</script>
